/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：Transfer                                                    
*│　作    者：NetCoreCMS                                            
*│　版    本：1.0    模板代码自动生成                                                
*│　创建时间：2019-12-25 10:52:46                             
*└──────────────────────────────────────────────────────────────┘
*┌──────────────────────────────────────────────────────────────┐
*│　命名空间： NetCoreCMS.Services                                  
*│　类    名： TransferService                                    
*└──────────────────────────────────────────────────────────────┘
*/
using NetCoreCMS.IRepository;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetCoreCMS.Services
{
    public class TransferService: ITransferService
    {
        private readonly ITransferRepository _repository;
        private readonly IUsersRepository _users;

        public TransferService(ITransferRepository repository, IUsersRepository users)
        {
            _repository = repository;
            _users = users;
        }
        public List<Models.Transfer> GetList(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null)
        {
            return _repository.GetListPaged(pageNumber, rowsPerPage, conditions, orderby, parameters).ToList();
        }
        public int RecordCount(string conditions, object parameters = null)
        {
            return _repository.RecordCount(conditions, parameters);
        }
        public bool Delete(int id)
        {
            return _repository.Delete(id) > 0;
        }

        public bool Add(Transfer model)
        {
            if (_users.Transfer(model))
            {
                return _repository.Insert(model) > 0;
            }
            return false;
        }
    }
}